package com.liuhuanss.voiceprint.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 声纹识别配置属性类
 * 用于读取application.yml中的声纹识别相关配置
 */
@Component
@ConfigurationProperties(prefix = "voiceprint")
public class VoiceprintProperties {

    private Api api = new Api();
    private Audio audio = new Audio();
    private Recognition recognition = new Recognition();

    public Api getApi() {
        return api;
    }

    public void setApi(Api api) {
        this.api = api;
    }

    public Audio getAudio() {
        return audio;
    }

    public void setAudio(Audio audio) {
        this.audio = audio;
    }

    public Recognition getRecognition() {
        return recognition;
    }

    public void setRecognition(Recognition recognition) {
        this.recognition = recognition;
    }

    /**
     * API配置
     */
    public static class Api {
        private String url;
        private String appId;
        private String apiKey;
        private String apiSecret;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getApiKey() {
            return apiKey;
        }

        public void setApiKey(String apiKey) {
            this.apiKey = apiKey;
        }

        public String getApiSecret() {
            return apiSecret;
        }

        public void setApiSecret(String apiSecret) {
            this.apiSecret = apiSecret;
        }
    }

    /**
     * 音频配置
     */
    public static class Audio {
        private long maxSize;
        private String[] allowedFormats;
        private int sampleRate;
        private int bitDepth;
        private int channels;
        private String encoding;

        public long getMaxSize() {
            return maxSize;
        }

        public void setMaxSize(long maxSize) {
            this.maxSize = maxSize;
        }

        public String[] getAllowedFormats() {
            return allowedFormats;
        }

        public void setAllowedFormats(String[] allowedFormats) {
            this.allowedFormats = allowedFormats;
        }

        public int getSampleRate() {
            return sampleRate;
        }

        public void setSampleRate(int sampleRate) {
            this.sampleRate = sampleRate;
        }

        public int getBitDepth() {
            return bitDepth;
        }

        public void setBitDepth(int bitDepth) {
            this.bitDepth = bitDepth;
        }

        public int getChannels() {
            return channels;
        }

        public void setChannels(int channels) {
            this.channels = channels;
        }

        public String getEncoding() {
            return encoding;
        }

        public void setEncoding(String encoding) {
            this.encoding = encoding;
        }
    }

    /**
     * 识别阈值配置
     */
    public static class Recognition {
        /**
         * 声纹相似度阈值，范围0.0-1.0，值越高要求越严格
         */
        private double similarityThreshold = 0.89;
        
        /**
         * 声纹识别阈值，范围0.0-1.0，值越高要求越严格
         */
        private double voiceprintThreshold = 0.89;

        public double getSimilarityThreshold() {
            return similarityThreshold;
        }

        public void setSimilarityThreshold(double similarityThreshold) {
            this.similarityThreshold = similarityThreshold;
        }

        public double getVoiceprintThreshold() {
            return voiceprintThreshold;
        }

        public void setVoiceprintThreshold(double voiceprintThreshold) {
            this.voiceprintThreshold = voiceprintThreshold;
        }
    }
}